<%--
  Created by IntelliJ IDEA.
  User: KaiFaBu010
  Date: 2017-12-13
  Time: 11:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <jsp:include page="/WEB-INF/jsp/head.jsp">
        <jsp:param value="特殊交易信息管理" name="pageTitle"/>
    </jsp:include>
    <script src="/js/common.js"></script>
</head>

<style>
    a:link {color:green;}
    a:hover {color:#FF00FF;}
</style>
<body class="easyui-layout">


<div class="easyui-panel" data-options="fit:true" style="width:100%;height:100%;padding:10px;">
    <table id="specialDelTb" class="easyui-datagrid" style="width:100%;height:100%">

    </table>
    <div id="tb" style="padding:20px;width:100%;">

        <a id="lbtnAdd" title="新增特殊交易" href="#"  class="easyui-linkbutton" style="width:80px;"><i class="fa fa-plus"></i>新增</a>
        <a id="lbtnAlter" title="修改特殊交易" href="#"  class="easyui-linkbutton" style="width:80px;"><i class="fa fa-plus"></i>修改</a>
        <a id="lbtnDel" href="#" class="easyui-linkbutton"style="width:80px;"><i class="fa fa-trash-o"></i>删除记录</a>
        <a id="flush_btn" href="#" class="easyui-linkbutton"style="width:80px; "><i class="fa fa-refresh"></i>刷新</a>

        <input type="text" class="yj-text" id="ssbegin" name="ssbegin" style="width: 80px;" readonly="readonly" onclick="WdatePicker({maxDate:'%y-%M-%d',dateFmt:'yyyy-MM-dd'})" value=""/>
        <input type="text" class="yj-text" id="ssend" name="ssend" style="width: 80px;" readonly="readonly" onclick="WdatePicker({maxDate:'%y-%M-%d',dateFmt:'yyyy-MM-dd'})" value=""/>
        <div id="User">
            <select id="helpeduid" class="yj-select helpeduid" name="helpeduid" ></select>
            <span class="msg-box" for="helpeduid" style="position:absolute;"></span>
        </div>
        <a id="lbtnFind" href="#" class="easyui-linkbutton"style="width:80px; "><i class="fa fa-refresh"></i>搜索</a>
    </div>
</div>


<script>
    //用户搜索选择
    $('#User').cxSelect({
            url: '/user/getAll',
            selects: ['uid'],
            emptyStyle: 'none',
            jsonName: 'relname',
            jsonValue: 'uid'
        }
    );

    $(function(){

        //刷新
        $("#flush_btn").click(function(){
            location.reload();
        });


        $('#lbtnFind').click(function (e) {
            e.preventDefault();
            e.stopPropagation();
            var ssbegin = $('#ssbegin').val();
            var ssend = $('#ssend').val();
            var helpeduid = $('#helpeduid').val();
            $("#specialDelTb").datagrid("load",{ssbegin: ssbegin, ssend: ssend,helpeduid:helpeduid});
        });


        //新增特殊交易显示
        $('#lbtnAdd').click( function (e) {
            e.preventDefault();
            e.stopPropagation();
            window.location.href = "/#";
        });




        //修改项目信息
        $('#lbtnAlter').click(function (e) {
            e.preventDefault();
            e.stopPropagation();
            var rows = $('#specialDelTb').datagrid('getSelections');

            if (rows.length == 0 || rows.length>1) {
                $.messager.show({
                    title: '修改项目信息',
                    msg: "必须选择一项进行修改",
                    timeout: 5000,
                    showType: 'slide'
                });
            }

            if (rows.length == 1){
                var row = $('#specialDelTb').datagrid('getSelected');
                var sid = row.sid;
                var url = "/#?sid=" + sid;
                self.location.href = url;
            }

        })


//END
    });


    //批量删除
    $("#lbtnDel").click(function(){
        var rows = $('#specialDelTb').datagrid('getSelections');
        if(rows.length != 1){
            $.messager.show({
                title:'删除项目',
                msg:"未选中记录",
                timeout:5000,
                showType:'slide'
            });
        }
        if(rows.length == 1){
            $.messager.confirm("删除警告", "您确定要删除"+rows.length+"记录吗？", function (data) {
                if (data) {
                    var row = $('#specialDelTb').datagrid('getSelected');
                    var sid = row.sid;
                    $.ajax({
                        type:"POST",
                        url:"/#",
                        data:{
                            "deleteId":sid
                        },
                        dataType:"json",
                        success: function(data){
                            $.messager.show({
                                title:'删除项目基本信息',
                                msg:data["msg"],
                                timeout:5000,
                                showType:'slide'
                            });

                        }
                    })
                }
                else {}
            });
        }
    });



    $('#specialDelTb').datagrid({
        iconCls: 'icon-search',
        title: '特殊交易基本信息',
        url: '/specialDeal/getAll',
        queryParams: {ssbegin: "", ssend: ""},
        method: 'get',
        singleSelect: "false",
        checkOnSelect: 'false',
        rownumbers: true,
        pagination: true,
        toolbar: '#tb',
        pageSize: 20,
        pageList: [10, 20, 30],
        columns: [[
            {field: 'ck', checkbox: true}
            , {field: 'sid', align: 'center', width: '100', title: '特殊支出ID', hidden: "true"}
            , {field: 'bid', width: '300',align: 'left', title: '支出的银行ID', hidden: "true"}
            , {field: 'alias', width: '100',align: 'left', title: '支出的银行别名'}
            , {field: 'specialexpend', align: 'left', width: '100', title: '特殊支出的金额',formatter:formatNumber}
            , {field: 'setype', align: 'left', width: '200', title: '特殊支出的类型',
                formatter:function (val) {
                    if (val == '0') {
                        return '内部提现'
                    } else if (val == '1') {
                        return '工作室费用'
                    }else if (val == '2') {
                        return 'Q币提取'
                    }
            }}
            , {field: 'handlerid', align: 'right', width: '100', title: '操作者ID', hidden: "true"}
            , {field: 'handlers', align: 'left', width: '100', title: '操作者'}
            , {field: 'remark', align: 'left', width: '100', title: '其他说明'}
            , {field: 'modifytime', align: 'center', width: '100', title: '记录时间',formatter:formatDatebox}

        ]],onLoadSuccess: function (data) {
            if (data.total == 0) {
                $.messager.alert('提示信息', '没有相关记录！', 'warning');
            }
        }
    });

</script>
</body>
</html>
